package com.sample.controller.datastore.ex2;


import java.util.List;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;

import com.google.appengine.api.datastore.Entity;
import com.sample.service.datastore.ex3.QueryTest;
import com.sample.util.CustomQuery;

public class IndexController extends Controller {

    @Override
    public Navigation run() throws Exception {

        CustomQuery query = new CustomQuery("Goods");

        List<Entity> list = query.asList();

        // stubデータ投入
        if (query.asList().size() == 0)  {
            QueryTest.putData();
        }

        requestScope("result", list.iterator());

        return forward("index.jsp");
    }
}
